<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:pls="http://www.w3.org/2005/01/pronunciation-lexicon" xmlns:ssml="http://www.w3.org/2001/10/synthesis" xmlns:svg="http://www.w3.org/2000/svg">
  <head>
    <title>Formatting XML</title>
    <link rel="stylesheet" type="text/css" href="docbook-epub.css"/>
    <link rel="stylesheet" type="text/css" href="kawa.css"/>
    <script src="kawa-ebook.js" type="text/javascript"/>
    <meta name="generator" content="DocBook XSL-NS Stylesheets V1.79.1"/>
    <link rel="prev" href="XML-tools.xhtml" title="Working with XML and HTML"/>
    <link rel="next" href="Creating-HTML-nodes.xhtml" title="Creating HTML nodes"/>
  </head>
  <body>
    <header/>
    <section class="sect1" title="Formatting XML" epub:type="subchapter" id="Formatting-XML">
      <div class="titlepage">
        <div>
          <div>
            <h2 class="title" style="clear: both">Formatting XML</h2>
          </div>
        </div>
      </div>
      <p>The easiest way to generate HTML or XML output is to run Kawa
with the appropriate <a class="link" href="Named-output-formats.xhtml" title="Named output formats"><code class="literal">--output-format</code> option</a>.
</p>
      <p>The intentation is that these output modes should be compatible with
<a class="ulink" href="http://www.w3.org/TR/2006/PR-xslt-xquery-serialization-20061121/" target="_top">XSLT 2.0 and XQuery 1.0 Serialization</a>.
(However, that specifies many options, most
of which have not yet been implemented.
</p>
      <div class="variablelist" epub:type="list">
        <dl class="variablelist">
          <dt class="term"><code class="literal">xml</code>
</dt>
          <dd>
            <p>Values are printed in XML format.
"Groups" or "elements" are written as using xml element syntax.
Plain characters (such as ‘<code class="literal">&lt;</code>’) are escaped (such as ‘<code class="literal">&amp;lt;</code>’).
</p>
          </dd>
          <dt class="term"><code class="literal">xhtml</code>
</dt>
          <dd>
            <p>Same as <code class="literal">xml</code>, but follows the xhtml compatibility guidelines.
</p>
          </dd>
          <dt class="term"><code class="literal">html</code>
</dt>
          <dd>
            <p>Values are printed in HTML format.
Mostly same as <code class="literal">xml</code> format, but certain elements without body,
are written without a closing tag.   For example <code class="literal">&lt;img&gt;</code> is written
without <code class="literal">&lt;/img&gt;</code>, which would be illegal for html, but required for xml.
Plain characters (such as ‘<code class="literal">&lt;</code>’) are not escaped inside <code class="literal">&lt;script&gt;</code>
or <code class="literal">&lt;style&gt;</code> elements.
</p>
          </dd>
        </dl>
      </div>
      <p>To illustrate:
</p>
      <pre class="screen">$ kawa --output-format html
#|kawa:1|# (html:img src:"img.jpg")
&lt;img src="img.jpg"&gt;
</pre>
      <pre class="screen">$ kawa --output-format xhtml
#|kawa:1|# (html:img src:"img.jpg")
&lt;img xmlns="http://www.w3.org/1999/xhtml" src="img.jpg" /&gt;
</pre>
      <pre class="screen">$ kawa --output-format xml
#|kawa:1|# (html:img src:"img.jpg")
&lt;img xmlns="http://www.w3.org/1999/xhtml" src="img.jpg"&gt;&lt;/img&gt;
</pre>
      <p>And here is the default <code class="literal">scheme</code> formatting:
</p>
      <pre class="screen">$ kawa
#|kawa:1|# (html:img src:"img.jpg")
({http://www.w3.org/1999/xhtml}img src: img.jpg )
</pre>
      <p class="synopsis" kind="Procedure"><span class="kind">Procedure</span><span class="ignore">: </span><a id="idm139667870685840" class="indexterm"/> <code class="function">as-xml</code> <em class="replaceable"><code>value</code></em></p>
      <div class="blockquote">
        <blockquote class="blockquote">
          <p>Return a value (or multiple values) that when printed will
print <em class="replaceable"><code>value</code></em> in XML syntax.
</p>
          <pre class="screen">(require 'xml)
(as-xml (make-element 'p "Some " (make-element 'em "text") "."))
</pre>
          <p>prints <code class="literal">&lt;p&gt;Some &lt;em&gt;text&lt;/em&gt;.&lt;/p&gt;</code>.
</p>
        </blockquote>
      </div>
      <p class="synopsis" kind="Procedure"><span class="kind">Procedure</span><span class="ignore">: </span><a id="idm139667870680880" class="indexterm"/> <code class="function">unescaped-data</code> <em class="replaceable"><code>data</code></em></p>
      <div class="blockquote">
        <blockquote class="blockquote">
          <p>Creates a special value which causes <code class="literal">data</code> to be printed,
as is, without normal escaping.  For example, when the output format
is XML, then printing <code class="literal">"&lt;?xml?&gt;"</code> prints as ‘<code class="literal">&amp;lt;?xml?&amp;gt;</code>’,
but <code class="literal">(unescaped-data "&lt;?xml?&gt;")</code> prints as  ‘<code class="literal">&lt;?xml?&gt;</code>’.
</p>
        </blockquote>
      </div>
    </section>
    <footer>
      <div class="navfooter">
        <p>
          Up: <a accesskey="u" href="XML-tools.xhtml">Working with XML and HTML</a></p>
        <p>
        Next: <a accesskey="n" href="Creating-HTML-nodes.xhtml">Creating HTML nodes</a></p>
      </div>
    </footer>
  </body>
</html>
